package com.example.lenovo.findmyclass.Buildings;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import com.example.lenovo.findmyclass.MainActivity;
import com.example.lenovo.findmyclass.R;

import java.util.Calendar;
import java.util.TimeZone;

public class BuildingThree extends Activity {
    private Button back;
    Calendar cal;
    private TextView time;
    private String year,month,week,day;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_building_three);
        back = findViewById(R.id.back);
        time=findViewById(R.id.time);
        back=findViewById(R.id.back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(BuildingThree.this, MainActivity.class);
                startActivity(intent);
            }
        });
        cal = Calendar.getInstance();
        cal.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));

        year = String.valueOf(cal.get(Calendar.YEAR));
        month = String.valueOf(cal.get(Calendar.MONTH)+1);
        week = String.valueOf(cal.get(Calendar.DAY_OF_WEEK));
        if("1".equals(week)){
            week ="天";
        }else if("2".equals(week)){
            week ="一";
        }else if("3".equals(week)){
            week ="二";
        }else if("4".equals(week)){
            week ="三";
        }else if("5".equals(week)){
            week ="四";
        }else if("6".equals(week)){
            week ="五";
        }else if("7".equals(week)){
            week ="六";
        }
        day = String.valueOf(cal.get(Calendar.DATE));
        time.setText(year+"年"+month+"月"+day+"日"+"周"+week);
    }
}
